package homework.server.terminal.impl;

import homework.server.terminal.Command;
import homework.server.terminal.Terminal;

public class GetVariableCommand implements Command {
    @Override
    public int execute(String[] args, Terminal terminal) throws Exception {

        if(args == null || args.length == 0) throw new IllegalArgumentException("缺少参数");

        for(String each: args) {
            String v = terminal.getVariable(each);
            if(v == null) v = "";
            terminal.getIOStream().writeLine(each+" = "+v);
        }

        return 0;
    }
}
